home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_003 / cforth / forth.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  124 lines

  1. /*
  2.  * forth.h -- define function numbers for primitives, and other constants,
  3.  * externals, and globals used in forth.c and prims.c
  4.  */
  5.  
  6. #define EXECUTE        0
  7. #define LIT        1
  8. #define BRANCH        2
  9. #define ZBRANCH        3
  10. #define PLOOP        4
  11. #define PPLOOP        5
  12. #define PDO        6
  13. #define I        7
  14. #define R        58
  15. #define DIGIT        8
  16. #define PFIND        9
  17. #define ENCLOSE        10
  18. #define KEY        11
  19. #define PEMIT        12
  20. #define QTERMINAL    13
  21. #define CMOVE        14
  22. #define USTAR        15
  23. #define USLASH        16
  24. #define AND        17
  25. #define OR        18
  26. #define XOR        19
  27. #define SPFETCH        20
  28. #define SPSTORE        21
  29. #define RPFETCH        22
  30. #define RPSTORE        23
  31. #define SEMIS        24
  32. #define LEAVE        25
  33. #define TOR        26
  34. #define FROMR        27
  35. #define ZEQ        28
  36. #define ZLESS        29
  37. #define PLUS        30
  38. #define DPLUS        31
  39. #define MINUS        32
  40. #define DMINUS        33
  41. #define OVER        34
  42. #define DROP        35
  43. #define SWAP        36
  44. #define DUP        37
  45. #define TDUP        38
  46. #define PSTORE        39
  47. #define TOGGLE        40
  48. #define FETCH        41
  49. #define CFETCH        42
  50. #define TFETCH        43
  51. #define STORE        44
  52. #define CSTORE        45
  53. #define TSTORE        46
  54. #define DOCOL        47
  55. #define DOCON        48
  56. #define DOVAR        49
  57. #define DOUSE        50
  58. #define SUBTRACT    51
  59. #define EQUAL        52
  60. #define NOTEQ        53
  61. #define LESS        54
  62. #define ROT        55
  63. #define DODOES        56
  64. #define DOVOC        57
  65. /* 58 is above */
  66. #define ALLOT        59
  67. #define PBYE        60
  68. #define TRON        61
  69. #define TROFF        62
  70. #define DOTRACE        63
  71. #define PRSLW        64
  72. #define PSAVE        65
  73. #define PCOLD        66
  74.  
  75. /* memory */
  76. #define GULPFRQ        256    /* if mem[LIMIT] - dp < GULPFRQ, then get */
  77. #define GULPSIZE    1024    /* a block of GULPSIZE words          */
  78.  
  79. /*
  80.  * User variables and other locations
  81.  */
  82.  
  83. #define S0    UP+0        /* csp when stack is empty */
  84. #define R0    UP+1        /* rsp when r stack is empty */
  85. #define TIB    UP+2        /* Terminal Input Buffer location */
  86. #define WIDTH    UP+3        /* screen width */
  87. #define WARNING    UP+4        /* print messages? */
  88. #define FENCE    UP+5        /* can not forget below this mark */
  89. #define DP    UP+6        /* points to first unallocated word */
  90. #define VOCLINK UP+7        /* vocabulary link */
  91.  
  92. char *calloc(), *realloc(), *gets();
  93. long lseek();
  94.  
  95. /* GLOBALS */
  96.  
  97. /* STACK POINTERS are registers of our FORTH machine. They, like everything
  98.    else, point into memory (mem[]). They are read by sp@ and rp@, set by sp!
  99.    and rp!. They are initialized by COLD. */
  100.  
  101. extern unsigned short csp;
  102. extern unsigned short rsp;
  103.  
  104. /* This variable is all-important. It will be set to the top of the 
  105.    data area by sbrk, and more memory will be allocated. All memory is
  106.    addressed as a subscript to this address -- mem[0] is the first memory 
  107.    element, mem[1] is second, and so on. 
  108. */
  109.  
  110. extern short *mem;    /* points to the number of bytes in mem[0], as read
  111.                from COREFILE at startup */
  112.  
  113. /* two more machine registers: the interpretive pointer */
  114. extern unsigned short ip;    /* for an explanation of these, look in */
  115. extern unsigned short w;    /* interp.doc */
  116.  
  117. extern int trace, debug;    /* global for tracing in next() */
  118. extern int tracedepth, breakenable, breakpoint, qtermflag, forceip, nobuf;
  119. extern FILE *blockfile;
  120. extern long bfilesize;
  121. extern char *bfilename;
  122. extern char *cfilename;
  123. extern char *sfilename;
  124.